]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
background: Inherit Animation from GnomeDesktop.BGSlideShow
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 28 May 2019 23:21:51 +0000 (01:21 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Fri, 8 Nov 2019 23:12:47 +0000 (23:12 +0000)
Animation background is just wrapping a native GnomeDesktop BGSlideShow
object, so instead of using composition we can now just inherit from the
native GObject, re-using native properties when possible, and avoiding
to keep an extra wrapper to the bg file.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/563

js/ui/background.js

index f99ad381c1ce216c661bff4681a7a27cb2c13550..4dde09101da2dc13d55f6ba85ff3fec09493a43b 100644 (file)
@@ -625,11 +625,11 @@ var BackgroundSource = class BackgroundSource {
     }
 };
 
-var Animation = class Animation {
-    constructor(params) {
-        params = Params.parse(params, { file: null });
+var Animation = GObject.registerClass(
+class Animation extends GnomeDesktop.BGSlideShow {
+    _init(params) {
+        super._init(params);
 
-        this.file = params.file;
         this.keyFrameFiles = [];
         this.transitionProgress = 0.0;
         this.transitionDuration = 0.0;
@@ -637,9 +637,7 @@ var Animation = class Animation {
     }
 
     load(callback) {
-        this._show = new GnomeDesktop.BGSlideShow({ file: this.file });
-
-        this._show.load_async(null, () => {
+        this.load_async(null, () => {
             this.loaded = true;
             if (callback)
                 callback();
@@ -649,13 +647,11 @@ var Animation = class Animation {
     update(monitor) {
         this.keyFrameFiles = [];
 
-        if (!this._show)
+        if (this.get_num_slides() < 1)
             return;
 
-        if (this._show.get_num_slides() < 1)
-            return;
-
-        let [progress, duration, isFixed_, filename1, filename2] = this._show.get_current_slide(monitor.width, monitor.height);
+        let [progress, duration, isFixed_, filename1, filename2] =
+            this.get_current_slide(monitor.width, monitor.height);
 
         this.transitionDuration = duration;
         this.transitionProgress = progress;
@@ -666,8 +662,7 @@ var Animation = class Animation {
         if (filename2)
             this.keyFrameFiles.push(Gio.File.new_for_path(filename2));
     }
-};
-Signals.addSignalMethods(Animation.prototype);
+});
 
 var BackgroundManager = class BackgroundManager {
     constructor(params) {